import java.util.ArrayList;

	abstract class message {
		private String content;	// give every message a content
		private String date;     //give every message a date
		private int ID;     //give every user a ID to recognize
		
		
		
		abstract boolean writeNewMessage(String content, String date);
		//abstract void remove(String color);
		
		
		protected String getcontent(){
			return content;
		}

		protected void setcontent(String content){
			this.content = content;
		}

		protected void setdate(String date){
			this.date = date;
			
		}
		protected String getdate(){
			return date;
		}

		
	}

	abstract class messageEditor {
		private ArrayList<message> messageList = new ArrayList<message>(); // an arrayList to store labels

		boolean writeNewMessage(String content, String date){
			try {
				System.out.println("write message : " + content);
				
				/*
				 * and do something else here
				 */
				message doc = writeMessage();
				doc.setcontent(content);
				doc.setdate(date);
				doc.writeNewMessage(content,date);
				messageList.add(doc);
			}
			catch (Exception e) {
				System.out.println("fail adding : " + content);
				return false;
			}
			return true;
		}
		void remove(String content){
			int nowIndex = -1, removeIndex = -1;  
			
			for(message doc : messageList) {
				nowIndex++;
				if(doc.getcontent() == content); {  
					removeIndex = nowIndex;
				}
			}	
			
			if(removeIndex > -1) {  
				messageList.remove(removeIndex);
			    System.out.println("delete message : " + content +" succeed");
			}
			else {
				System.out.println("delete " + content + " message failed");
			}
		}

		int getNumOfUser(){
			return messageList.size();
		}
		abstract message writeMessage();
	}

	class messageInfor extends messageEditor {
		message writeMessage (){
			return new message () {
				boolean writeNewMessage(String content, String date){ 
					System.out.println("write message : " + content +" succeed");
					return true; 
				}
				void remove(String content){
					System.out.println("delete user : " + content +" succeed");
				}			
				
			};
		}
	}	